﻿using UnityEngine;

//Version 1.1
// 调整屏幕内容缩放(比例)大小

public class InitSize : MonoBehaviour
{
	[Tooltip("实际屏幕大小，硬件的分辨率")]
	public Vector2Int screen_size = new Vector2Int(1920, 1080); //实际屏幕大小
	[Tooltip("是否执行缩放")]
	public bool if_resize = false;
	[Tooltip("是否循环执行")]
	public bool if_loop = false;


	// Start is called before the first frame update
	void Start()
	{
		if (if_resize)
		{
			//调整大小
			ScreenReset();
			Invoke("ScreenReset", 5f);
		}
		if (if_loop)
		{
			InvokeRepeating("ScreenReset", 10, 15);
		}
	}


	/// <summary>
	/// 屏幕调整（大小与前置）
	/// </summary>
	private void ScreenReset()
	{
		// 根据设备显示调整分辨率
		if ((int)Screen.width != screen_size.x || (int)Screen.height != screen_size.y)
		{
			Screen.SetResolution(screen_size.x, screen_size.y, true);
		}
	}
}
